<?php PageUtil::addVar("stylesheet","<link href=\"".$stylepath."/forum.css\" rel=\"stylesheet\">");?>
<!-- tiny mce -->
<script src="<?php echo base_url('/themes/Theme01/js/tinymce/tinymce.dev.js'); ?>"></script>
<script>
  tinymce.init({
    selector: "textarea#elm1",
    theme: "modern",
    menubar : false,
    height : 350,
    plugins: [
      "advlist autolink  image lists charmap print preview hr anchor pagebreak spellchecker",
      "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
      "save table contextmenu directionality emoticons template paste textcolor importcss"
    ],
    external_plugins: {
      //"moxiemanager": "/moxiemanager-php/plugin.js"
    },
    content_css: "css/development.css",
    add_unload_trigger: false,

    toolbar: "insertfile undo redo | bold italic | alignleft aligncenter alignright alignjustify | forecolor fullpage backcolor  preview  ",

    image_advtab: true,

    style_formats: [
      {title: 'Bold text', format: 'h1'},
      {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
      {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
      {title: 'Example 1', inline: 'span', classes: 'example1'},
      {title: 'Example 2', inline: 'span', classes: 'example2'},
      {title: 'Table styles'},
      {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
    ],

    setup: function(ed) {
      /*ed.on(
        'Init PreInit PostRender PreProcess PostProcess BeforeExecCommand ExecCommand Activate Deactivate ' +
        'NodeChange SetAttrib Load Save BeforeSetContent SetContent BeforeGetContent GetContent Remove Show Hide' +
        'Change Undo Redo AddUndo BeforeAddUndo', function(e) {
        console.log(e.type, e);
      });*/
    },

    spellchecker_callback: function(method, words, callback) {
      if (method == "spellcheck") {
        var suggestions = {};

        for (var i = 0; i < words.length; i++) {
          suggestions[words[i]] = ["First", "second"];
        }

        callback(suggestions);
      }
    }
  });
</script>
<!-- tiny mce -->
<div class="left_content">
	<form action="<?php echo base_url('forum/add'); ?>" method="post" class="form-horizontal" enctype="multipart/form-data">
		<legend>โพสกระทู้</legend>
		<div class="control-group">
      <label class="control-label" for="name">หัวข้อกระทู้</label>
      <div class="controls">
				<input type="text" name="title" class="span6"/>
	      </div>
	    </div>
      <div class="control-group">
        <label class="control-label" for="Username">หมวดหมู่</label>
        <div class="controls">
          <select name="cat_id">
            <option value="0">โปรดเลือก</option>
            <?php
              echo Util::buildCategoriesOptionList(0,$categories,"",$this->uri->segment(3));
            ?>
          </select>
        </div>
      </div>
	    <div class="control-group">
        <label class="control-label" >เนื้อหากระทู้</label>
        	<div class="controls">
  			<textarea id="elm1" class="post-form-textarea input-xlarge required span6" name="content"  ></textarea>
  		    </div>
      </div>

      <div class="control-group">
        <label class="control-label" >รูปภาพประกอบ</label>
        <div class="controls">
          <input type="file" name="filename[]" class="upload_main" />
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
          <input type="file" name="filename[]" class="upload_main" /> <br / >
        </div>
      </div>

		<div class="control-group">
	      <div class="controls">
					<input type="submit" name="submit" value="submit"  class="btn btn-primary" /> &nbsp;
					<input type="reset" name="cancel" value="cancel"  class="btn" />
	      </div>
	    </div>
	</form>
</div>